/**
 * Project: complex.quartz
 * 
 * File Created at 2010-6-29
 * $Id$
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.complex.quartz;

import org.quartz.CronExpression;
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @description:使用cron来定义触发器
 * @author gaoliang
 * @date 2010-6-29
 * @version 1.0
 */
public class CronTriggerRunner {
    public static void main(String[] args) {
        try {

            JobDetail jobDetail = new JobDetail("job1_2", "jGroup1", SimpleJob.class);

            //创建CronTrigger，指定组及名称

            CronTrigger cronTrigger = new CronTrigger("trigger1_2", "tgroup1");

            //定义Cron表达式
            CronExpression cexp = new CronExpression("0/5 * * * * ?");

            //设置Cron表达式
            cronTrigger.setCronExpression(cexp);

            SchedulerFactory schedulerFactory = new StdSchedulerFactory();

            Scheduler scheduler = schedulerFactory.getScheduler();

            scheduler.scheduleJob(jobDetail, cronTrigger);

            scheduler.start();

        } catch (Exception e) {

            e.printStackTrace();

        }

    }
}
